import os
from analysis import backtest
# from pre_process.read_data import read_train_n_test_data

from pre_process.technical_factor import add_factor
from process import svm, random_forest, bp

DATA_PATH = './data'
DATA_DIR = os.listdir(DATA_PATH)

MODEL_PATH = './models'
MODEL_LIST = ['svm', 'bp', 'rf']

for i in range(len(DATA_DIR)):
    dir = '%s/%s' % (DATA_PATH, DATA_DIR[i])
    symbol = DATA_DIR[i].replace('.csv', '')
    # pre process the data ma_5, ma_10, rsi, bollin
    # add_factor(dir)
    # training
    # bp.train_and_test(dir, symbol)
    # svm.train_and_test(dir, symbol)
    # random_forest.train_and_test(dir, symbol)
    for j in range(len(MODEL_LIST)):
        model = MODEL_LIST[j]
        model_dir = '%s/%s_%s.pkl' % (MODEL_PATH, model, symbol)
        backtest.get_daily_pnl(dir, model_dir, symbol, model)
        # print(symbol, model, result)
        # continue
        # backtest.get_performance(result=result, symbol=symbol, model=model)
    # break


# backtest.get_daily_pnl('./data/AU.SHF.csv', './models/svm_AU.SHF.pkl', 'AU.SHF', 'svm')
